extends Area2D

@export var amount: int = 1
@onready var animation_player: AnimationPlayer = $AnimationPlayer
var coin_id: String


func _ready() -> void:
	coin_id = get_path()
	if GlobalGameData.collected_coins.has(coin_id):
		queue_free()

func _on_body_entered(_body: Node2D) -> void:
	GlobalGameData.change_coin(amount)
	GlobalGameData.collected_coins.append(coin_id)
	animation_player.play("collect")
	collision_mask = 0

	await animation_player.animation_finished
	queue_free()
